package com.jintian.smart.platform.system;

import com.jintian.smart.kernel.autoconfigure.beetl.EnableBeetlMapper;
import com.jintian.smart.kernel.common.listener.Ip2RegionListener;
import com.jintian.smart.kernel.common.listener.LogVariableListener;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * SmartAdmin 项目启动类
 */
@EnableCaching
@EnableScheduling
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
@ComponentScan(PlatformApplication.COMPONENT_SCAN)
@EnableDubbo(scanBasePackages = {"com.jintian.smart.**.provider"})
@EnableBeetlMapper(basePackages = {"com.jintian.smart.platform.system.mapper"}, sqlManager = "sqlManager", mapperSuffix = "Mapper")
@SpringBootApplication
public class PlatformApplication {
    public static final String COMPONENT_SCAN = "com.jintian.smart";

    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(PlatformApplication.class);
        // 添加 日志监听器，使 log4j2-spring.xml 可以间接读取到配置文件的属性
        application.addListeners(new LogVariableListener(), new Ip2RegionListener());
        ConfigurableApplicationContext context = application.run(args);
        
//        // 打印所有的BeanDefinition
//        String[] beanDefinitionNames = context.getBeanDefinitionNames();
//        System.out.println("=====================================");
//        System.out.println("总共找到 " + beanDefinitionNames.length + " 个 BeanDefinition:");
//        System.out.println("=====================================");
//        for (String beanName : beanDefinitionNames) {
//            System.out.println(beanName + " -> " + context.getBeanFactory().getBeanDefinition(beanName).getBeanClassName());
//        }
//        System.out.println("=====================================");
    }
}
